package com.xqls.quaz;


import com.xqls.biz.DrainFlowRecordBiz;
import com.xqls.biz.FlowRecordBiz;
import com.xqls.dal.model.Company;
import com.xqls.dal.model.DeviceSchema;
import com.xqls.util.ContextUtil;
import com.xqls.util.DictionaryEnums;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;

public class RecordDumpRunAble  {
     private Company deviceSchema;

    public RecordDumpRunAble(Company deviceSchema){
        this.deviceSchema=deviceSchema;

    }
    private static final Logger LOG = LoggerFactory
            .getLogger(RecordDumpRunAble.class);


    public Void call() {
        DictionaryEnums dictionaryEnums=DictionaryEnums.find(deviceSchema.getDeviceType());
        if(dictionaryEnums!=null){

            try{
                Map<String, Object> map = new HashMap<String, Object>();
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
                map.put("enterpriseNo", deviceSchema.getDeviceNo());
                map.put("date", sdf.format(new Date()));
                switch (dictionaryEnums){
                    case INTAKE:
                        FlowRecordBiz flowBiz = (FlowRecordBiz)ContextUtil.getBean(FlowRecordBiz.class);
                        flowBiz.generateRecord(map);
                        break;
                    case  DISCHARGE:
                        DrainFlowRecordBiz drainFlowRecordBiz= (DrainFlowRecordBiz)ContextUtil.getBean(DrainFlowRecordBiz.class);
                        drainFlowRecordBiz.generateRecord(map);

                }
            }catch (Exception e){
                LOG.error("TentNo"+ContextUtil.getTentNo() ,e);
            }

        }
       return null;

    }
}
